package com.pg.agent.engine.client.common.enums;

import java.util.Arrays;

/**
 * 组件类型
 *
 * @author huhuaping
 * @date 2024/02/29 9:41
 */
public enum ComponentTypeEnum {

    // 配置方式，1.接口，2.系统函数
    INTERFACE(1, "INTERFACE", "接口"),
    SYS_FUN(2, "SYS_FUN", "系统函数");

    /**
     * 值
     */
    private Integer value;
    /**
     * 编码
     */
    private String code;
    /**
     * 说明
     */
    private String desc;

    ComponentTypeEnum() {

    }

    ComponentTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    ComponentTypeEnum(Integer value, String code, String desc) {
        this.value = value;
        this.code = code;
        this.desc = desc;
    }

    public static String getCodeByValue(Integer value) {

        ComponentTypeEnum controllerTypeEnum = Arrays.stream(values()).filter(e -> e.value.equals(value)).findFirst().orElse(null);

        return controllerTypeEnum == null ? "" : controllerTypeEnum.code;
    }

    public Integer getValue() {
        return value;
    }


    public String getDesc() {
        return desc;
    }


    public String getCode() {
        return code;
    }

}
